R visualization workshop
Welcome
I Week I
Overview Week 1
1 R, Rstudio, and packages
2 ggplot – a quick overview
3 ggplot – some theory
4 ggplot – the geoms
5 Distribution of a single variable
6 Reproducible workflows
7 Class assignment
II Week 2
Overview Week 2
8 Comparing distributions
9 Using extension packages
10 Class assignment 2
III Week 3
Overview Week 3
11 Comparing group statistics
12 Transform data
13 Revisiting earlier graphs
14 Class assignment 3
IV Week 4
Overview Week 4
15 Visualizing two continuous variables
16 Revisiting earlier graphs 2
17 Figure size
18 Class assignment 4
V Assignments
Assignment 1
Assignment 2
Assignment 3
Assignment 4
◦ Preparation
◦ Visualization
◦ Submit your PDF-file online
VI Other useful stuff
Themes
Titles, text and legends
Scales, Axes & Coordinate systems
Colours
Facets
The legend
Saving plots
Importing data
Help!?
References
Published with bookdown
Assignment 4
Preparation
Download this Rmarkdown file, fill in your name and student number, and complete your assignment in the Rmarkdown file. “knit” your text and code into a pdf-file, and upload this pdf-file on Nestor before the next lecture. Make sure that your pdf-output looks correct.
Visualization
This is a historical dataset on the modern Olympic Games, including all the Games from Athens 1896 to Rio 2016. The data was retrieved from here.
Packages & Data
library(ggplot2)
library(tidyverse) # install.packages(“tidyverse”) if you haven’t done so
data <- read.csv("https://stulp.gmw.rug.nl/dataviz/athlete_events.csv",
header = TRUE)
head(data)
## ID Name Sex Age Height Weight Team NOC
## 1 1 A Dijiang M 24 180 80 China CHN
## 2 2 A Lamusi M 23 170 60 China CHN
## 3 3 Gunnar Nielsen Aaby M 24 NA NA Denmark DEN
## 4 4 Edgar Lindenau Aabye M 34 NA NA Denmark/Sweden DEN
## 5 5 Christine Jacoba Aaftink F 21 185 82 Netherlands NED
## 6 5 Christine Jacoba Aaftink F 21 185 82 Netherlands NED
## Games Year Season City Sport
## 1 1992 Summer 1992 Summer Barcelona Basketball
## 2 2012 Summer 2012 Summer London Judo
## 3 1920 Summer 1920 Summer Antwerpen Football
## 4 1900 Summer 1900 Summer Paris Tug-Of-War
## 5 1988 Winter 1988 Winter Calgary Speed Skating
## 6 1988 Winter 1988 Winter Calgary Speed Skating
## Event Medal
## 1 Basketball Men's Basketball
## 2 Judo Men’s Extra-Lightweight
## 3 Football Men’s Football
## 4 Tug-Of-War Men’s Tug-Of-War Gold
## 5 Speed Skating Women’s 500 metres
## 6 Speed Skating Women’s 1,000 metres
Your task
On the basis of data from the Olympic Games, try to create an informative and pretty graph. Include the following elements.
• Visualize the relationship between height and weight for both men and women.
• Multiple layers are encouraged.
• You can make use of the full dataset or you can make a selection (e.g., focussing on only one year/country/sport).
• Explain in no more than 250 words what the graph is showing, and what unique insights it delivers. Also reflect on what it fails to show or what you would have liked to include in the graph but was not able to.
• Create appropriate axis-labels and titles. Appropriate breaks/limits/labels are encouraged.
• Create your own theme and add this theme to your graph.
• Try to use different colours than the ggplot-standards.
• Be sure to create clean code (see here)
Submit your PDF-file online
When you are done with your assignment, try clicking the “Knit”-button in Rstudio so that your code will be knitted into a pdf-file. Submit this file on Nestor.
If you see an error appear, try to fix the error and try again. If you can’t get the “knitting” to work, then you can copy your code, text, and graphs into a word-file and submit it on Nestor.